package com.user.profile.service.user;

import com.user.profile.entity.UserEntity;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;

/**
 * @Author linlx
 * @Date 2021/9/22 11:42
 * @Description
 **/
@Service
public class CommonInsertBuild {

  public List<String> buildLabelInt(Map<Integer, List<UserEntity>> map, String temple) {
    List<String> resultList = new ArrayList<>();
    map.forEach((labelValue, list) -> {
      String ckSql = temple;
      ckSql = ckSql.replace("{0}", String.valueOf(labelValue));
      ckSql = ckSql.replace("{1}", Arrays.toString(list.stream().map(UserEntity::getId).toArray()));
      resultList.add(ckSql);
    });
    return resultList;
  }

  public List<String> buildLabelString(Map<String, List<UserEntity>> map, String temple) {
    List<String> resultList = new ArrayList<>();
    map.forEach((labelValue, list) -> {
      String ckSql = temple;
      ckSql = ckSql.replace("{0}", labelValue);
      ckSql = ckSql.replace("{1}", Arrays.toString(list.stream().map(UserEntity::getId).toArray()));
      resultList.add(ckSql);
    });
    return resultList;
  }


}
